import Vue from 'vue'
import 'babel-polyfill'
import App from './App.vue'
import router from '@/router'
import store from '@/store'
Vue.config.productionTip = false
let pluginsArr = require.context('@/plugins', false, /\w+\.(js)$/
)
pluginsArr = pluginsArr.keys().map(function (fileName) {
  const componentConfig = pluginsArr(fileName)
  return componentConfig.default
})
const len = pluginsArr.length
const runVue = function (index) {
  if (index > len) {
    store.commit('setLoading', false)
  } else {
    if (pluginsArr[index] && pluginsArr[index].constructor === Promise) {
      pluginsArr[index].then(function () {
        index++
        runVue(index)
      })
    } else {
      index++
      runVue(index)
    }
  }
}
runVue(0)
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
